package com.example.logspringbootstarter.aspect;


import com.example.logspringbootstarter.annotation.Log;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @author Senhai Xu
 */
@Aspect
public class LogAspect {
    @Pointcut("@annotation(log)")
    public void webLog(Log log) {
    }
    @Before(value = "webLog(log)", argNames = "joinPoint,log")
    public void doBefore(JoinPoint joinPoint, Log log) {
        System.out.println("before"+log);
    }
    @AfterReturning(returning = "res",pointcut = "webLog(log)", argNames = "res,log")
    public void doAfterReturning(Object res, Log log) {
        System.out.println("doAfterReturning"+log);
    }
}
